home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / Aminet / util / misc / MultiRen.lha / MultiRen / Developers / Test-Plugin.e < prev    next >
Encoding:
Text File  |  2000-05-03  |  3.0 KB  |  111 lines

  1. /* Test-plugin v1.0 by Deniil 715! for MultiRen
  2.    Made 2000-05-02
  3.    E-mail to me, Daniel Westerberg: deniil@algonet.se
  4. */
  5.  
  6. CONST NUMSTRINGS_FOR_THIS_PLUGIN=2, FILE_NAME_LENGTH=512,
  7.       COM_ASK=1, COM_EXTRACT=2, COM_CONFIGURE=3, COM_ABOUT=4, COM_QUIT=5,
  8.       ERR_OK=0,
  9.       ERR_NOMEM=1,
  10.       ERR_NOFILE=2,
  11.       ERR_NOSIG=3,
  12.       ERR_NOTIMPL=4,
  13.       ERR_UNKNOWN=5,
  14.       ERR_OTHER=6,
  15.       ERR_WRONGFORMAT=7,
  16.       ERR_FATAL=20
  17.  
  18. OBJECT multiren_plugin
  19.  id:LONG
  20.  task:LONG
  21.  sig:LONG
  22.  return:INT
  23.  command:CHAR
  24.  numstrings:CHAR
  25.  stringlist[256]:ARRAY OF LONG
  26.  name:PTR TO CHAR
  27. ENDOBJECT
  28.  
  29. DEF mrp:PTR TO multiren_plugin, hex[8]:STRING, ascii[4]:STRING
  30.  
  31. PROC main()
  32.  DEF sel, sigbit, sig, mtask, msig
  33.  '$VER: TestPlugin v1.0 by Deniil 715! (2000-05-02)'
  34.  IF arg
  35.   IF mrp:=Val(arg)
  36.    IF mrp.id="MRPO"
  37.     IF (sigbit:=AllocSignal(-1))>=0
  38.      sig:=Shl(1,sigbit)
  39.      LOOP
  40.       sel:=mrp.command
  41.       SELECT sel
  42.       CASE COM_ASK
  43.        mtask:=mrp.task
  44.        msig:=mrp.sig
  45.        mrp.return:=ask()
  46.        SetProgramName(mrp.name)
  47.        mrp.task:=FindTask(NIL)
  48.        mrp.sig:=sig
  49.       CASE COM_EXTRACT   ; mrp.return:=extract()
  50.       CASE COM_CONFIGURE ; mrp.return:=config()
  51.       CASE COM_ABOUT     ; mrp.return:=about()
  52.       CASE COM_QUIT
  53.        FreeSignal(sigbit)
  54.        mrp.return:=cleanup()
  55.        Signal(mtask,msig)
  56.        RETURN
  57.       DEFAULT ; mrp.return:=ERR_UNKNOWN
  58.       ENDSELECT
  59.       Signal(mtask,msig)
  60.       Wait(sig)
  61.      ENDLOOP
  62.     ELSE
  63.      Signal(mrp.task,mrp.sig)
  64.      mrp.return:=ERR_NOSIG
  65.      RETURN
  66.     ENDIF
  67.    ENDIF
  68.   ENDIF
  69.  ENDIF
  70.  WriteF('This is a plugin for MultiRen!\n' +
  71.         'It is not supposed to be executed manually!\n' +
  72.         'Use it through the Renplacer tool in MultiRen instead!\n')
  73. ENDPROC ERR_FATAL
  74.  
  75. PROC ask()
  76.  mrp.numstrings:=NUMSTRINGS_FOR_THIS_PLUGIN  -> I will return 2 strings
  77.  mrp.stringlist[0]:='First 4 bytes as hex'   -> Setting information-strings
  78.  mrp.stringlist[1]:='First 4 bytes as ASCII'
  79.  mrp.name:='Test Plugin'                     -> This plugins name
  80. ENDPROC ERR_OK
  81.  
  82. PROC extract() -> Do my stuff..
  83.  DEF fh, len
  84.  IF fh:=Open(mrp.name,OLDFILE) -> Open the file that later is going to be renamed.
  85.   len:=Read(fh,ascii,4)
  86.   Close(fh)
  87.   IF len<>4 THEN RETURN ERR_OTHER
  88.   SetStr(ascii,4)
  89.   StringF(hex,'\r\z\h\z\h\z\h\z\h',ascii[0],ascii[1],ascii[2],ascii[3])
  90.   mrp.stringlist[0]:=hex   -> Set the pointers so that MultiRen
  91.   mrp.stringlist[1]:=ascii -> can get my strings.
  92.   RETURN ERR_OK -> My stuff went ok
  93.  ENDIF
  94. ENDPROC ERR_NOFILE -> The file didn't open
  95.  
  96. PROC config() IS ERR_NOTIMPL -> There is no config for this plugin
  97.  
  98. PROC about()
  99.  IF req('Test Plugin v1.0 by Deniil 715! for MultiRen\n\n' +
  100.         'It was made 2000-04-02 in Amiga-E\n\n' +
  101.         'E-mail: deniil@algonet.se','More|OK')
  102.   req('This plugin will return the first 4 bytes\n' +
  103.       'of the file to rename in two ways. The first\n' +
  104.       'string will be the 4 bytes in hexadecimal,\n' +
  105.       'the other one just as a plain string.','OK')
  106.  ENDIF
  107. ENDPROC ERR_OK
  108.  
  109. PROC cleanup() IS ERR_OK
  110.  
  111. PROC req(body,gads) IS EasyRequestArgs(NIL,[20,0,'Test Plugin',body,gads],NIL,NIL)